package chamster.view;

import java.awt.Point;

public class PointUtils {
	public static Point subtract(Point p1, Point p2) {
		return new Point(p1.x - p2.x, p1.y - p2.y);
	}
	
	public static Point add(Point p1, Point p2) {
		return new Point(p1.x + p2.x, p1.y + p2.y);
	}
	
	public static Point multiply(Point p1, double times) {
		return new Point((int)(p1.getX() * times), (int)(p1.getY() * times));
	}
	
	public static double distance(Point p1, Point p2) {
		Point between = PointUtils.subtract(p2, p1);
		return Math.sqrt(Math.pow(between.getX(), 2) + Math.pow(between.getY(), 2));
	}
	
	public static Point multiplyMatrix(int[][] matrix, Point p) {
		int x = matrix[0][0]*p.x + matrix[0][1] * p.y;
		int y = matrix[1][0]*p.x + matrix[1][1] * p.y;
		return new Point(x, y);
	}
}
